package com.binc.testspring.study.nio.netty.encodeAndDecode;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * FileName: MyChannelInit
 * Autho: binC
 * Date:  2022/4/21 14:28
 */
public class MyServerChannelInit extends ChannelInitializer<SocketChannel> {

    /**

     */
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        pipeline.addLast(new MyByteToLongDecoder());//自定义的解码器   继承 ByteToMessageDecoder  重写 decode 方法 ; 完成目标是byte -> long
        pipeline.addLast(new MyByteToLongEncoder());//自定义的编码器   继承 MessageToByteEncoder  重写encode 方法 ; 完成目标是long ->byte
        pipeline.addLast(new MyServerHandler());// 业务处理器



    }
}
